<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .html{
            height: 100px;
            width: 100px;
            background-color: blue;
        }
        .css{
            height: 100px;
            width: 100px;
            background-color:chartreuse;
        }
        .current{
            color: crimson;
        }
    </style>
</head>
<body>
    <ul id="ul">
        <li>html</li>
        <li>css</li>
    </ul>
    <div class="parent">
        <div class="html" style="display: none;"></div>
        <div class="css"></div>
    </div>

    <script>
        var li = document.querySelectorAll("#ul li");
        var div = document.querySelectorAll(".parent div");
        for(let i=0;i<li.length;i++){
            li[i].index = i;
            li[i].onclick = function(){
                for(let i=0;i<li.length;i++){
                    li[i].classList.remove("current");
                }
                this.classList.add("current");

                for(let i=0;i<li.length;i++){
                    div[i].style.display = "none";
                }
                div[this.index].style.display = "block";
            }
        }
    </script>
</body>
</html>